/*
 * Copyright (c) 2012 swing-on-fire Team
 * 
 * This file is part of Swing-On-Fire (http://code.google.com/p/swing-on-fire), licensed under the terms of the MIT
 * License (MIT).
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
 * Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package com.google.code.swingonfire.utility.interpolation;

public class Interpolations
{

    private static final Interpolation ACCELERATING_INTERPOLATION = new AcceleratingInterpolation();
    private static final Interpolation SLOWING_INTERPOLATION = new SlowingInterpolation();
    private static final Interpolation ACCURATE_INTERPOLATION = new AccurateInterpolation();
    private static final Interpolation DOUBTFUL_INTERPOLATION = new DoubtfulInterpolation();
    private static final Interpolation LINEAR_INTERPOLATION = new LinearInterpolation();
    private static final Interpolation SOFT_INTERPOLATION = new SoftInterpolation();
    private static final Interpolation TOON_INTERPOLATION = new ToonInterpolation();

    public static double trimInterpolationValue(double value)
    {
        if (value < 0)
        {
            return 0;
        }

        if (value > 1)
        {
            return 1;
        }

        return value;
    }

    public static Interpolation accelerating()
    {
        return ACCELERATING_INTERPOLATION;
    }

    public static Interpolation slowing()
    {
        return SLOWING_INTERPOLATION;
    }

    public static Interpolation accurate()
    {
        return ACCURATE_INTERPOLATION;
    }

    public static Interpolation doubtful()
    {
        return DOUBTFUL_INTERPOLATION;
    }

    public static Interpolation envelope(Interpolation interpolation, Interpolation envelope)
    {
        return new EnvelopeInterpolation(interpolation, envelope);
    }

    public static Interpolation fix(double value)
    {
        return new FixInterpolation(value);
    }

    public static Interpolation inverse(Interpolation interpolation)
    {
        return new InverseInterpolation(interpolation);
    }

    public static Interpolation linear()
    {
        return LINEAR_INTERPOLATION;
    }

    public static Interpolation mirror(Interpolation interpolation)
    {
        return new MirrorInterpolation(interpolation);
    }

    public static Interpolation multiply(Interpolation interpolation, double start, double multiplier)
    {
        return new MultiplyInterpolation(interpolation, start, multiplier);
    }

    public static Interpolation repeat(Interpolation interpolation, int repeats)
    {
        return new RepeatInterpolation(interpolation, repeats);
    }

    public static Interpolation reverse(Interpolation interpolation)
    {
        return new ReverseInterpolation(interpolation);
    }

    public static Interpolation shake(int shakes)
    {
        return new ShakeInterpolation(shakes);
    }

    public static SequentialInterpolation sequential()
    {
        return new SequentialInterpolation();
    }

    public static Interpolation soft()
    {
        return SOFT_INTERPOLATION;
    }

    public static Interpolation toon()
    {
        return TOON_INTERPOLATION;
    }

}
